import App from './App'
import Vue from 'vue'
import VueI18n from 'vue-i18n'
import zh from './locale/zh-Hans.json'
import es from './locale/es.json'
import uView from "uview-ui";
import {router,RouterMount} from './router.js'  //路径换成自己的
import Decimal from "decimal.js"
import dateUtil from '@/common/utils/date-util.js'
import wsRequest from '@/common/utils/websocket.js'
import bluetooth  from "@/common/utils/linkBluetooth.js";
let websocket = new wsRequest()
Vue.use(VueI18n)
const i18n = new VueI18n({
	// 默认语言，这里的local属性，对应message中的es、zh属性,获取缓存语言没有就默认zh
	locale: uni.getStorageSync('lang')||'zh',
	// 引入语言文件
	messages: {
		// 这里的属性名是任意的，您也可以把zh设置为cn等，只是后续切换语言时
		// 要标识这里的语言属性，如：this.$i18n.locale = zh|en|zh|xxx
		'es': es, // 这里为上面通过import引入的语言包
		'zh': zh,
	}
})
Vue.prototype._i18n = i18n
import api from '@/common/request/index'
import * as filters from './common/utils/filters.js'
import $payment from '@/common/utils/payment.js'
import $helpers from '@/common/utils/helpers.js'
import configPath from './common/config/config.js'
import $login from '@/common/utils/login.js'
import $mWxQrCode from '@/common/utils/wxqrcode.js'
import navBar from '@/components/navbar/navbar.vue'
import $activityOrderStateEnum from '@/common/enum/activity-order-state.enum.js'
import $consumeRecordStateEnum from '@/common/enum/consume-record-state.enum.js'
import $activityOrderPayStateEnum from '@/common/enum/activity-order-pay-state.enum.js'
import $activityValidityTypeEnum from '@/common/enum/activity-validity-type.enum.js'
import $activityTypeEnum from '@/common/enum/activity-type.enum.js'
import $deviceTypeEnum from '@/common/enum/device-type.enum.js'
import $orderExchangeStatusEnum from '@/common/enum/order-exchange-status.enum.js'
import $orderExchangeTypeEnum from '@/common/enum/order-exchange-type.enum.js'
import $ticketPackageTypeEnum from '@/common/enum/ticket-package-type.enum.js'
import $activityOrderExchangeStateEnum from '@/common/enum/activity-order-exchange-state.enum.js'
import $shipmentStatusEnum from '@/common/enum/shipment-status.enum.js'
import $socketTypeEnum from '@/common/enum/socket-type.enum.js'
import $wxScan from '@/common/utils/wx-scan.js';
import $storageKeyEnum from '@/common/enum/storage-key.enum.js'

// #ifdef MP-WEIXIN || MP-ALIPAY
import loginPopup from '@/components/login-popup/login-popup.vue'
//#endif

Vue.prototype.$api = api;
Vue.prototype.$date = dateUtil;
Vue.prototype.$helpers = $helpers;
Vue.prototype.$payment = $payment;
Vue.prototype.$configPath = configPath;
Vue.prototype.$login = $login;
Vue.prototype.$mWxQrCode = $mWxQrCode;
Vue.prototype.$socket = websocket
Vue.prototype.Decimal = Decimal;
Vue.prototype.$activityOrderStateEnum = $activityOrderStateEnum;
Vue.prototype.$consumeRecordStateEnum = $consumeRecordStateEnum;
Vue.prototype.$activityOrderPayStateEnum = $activityOrderPayStateEnum;
Vue.prototype.$activityValidityTypeEnum = $activityValidityTypeEnum;
Vue.prototype.$activityTypeEnum = $activityTypeEnum;
Vue.prototype.$deviceTypeEnum = $deviceTypeEnum;
Vue.prototype.$orderExchangeStatusEnum = $orderExchangeStatusEnum;
Vue.prototype.$orderExchangeTypeEnum = $orderExchangeTypeEnum;
Vue.prototype.$ticketPackageTypeEnum = $ticketPackageTypeEnum;
Vue.prototype.$activityOrderExchangeStateEnum = $activityOrderExchangeStateEnum;
Vue.prototype.$shipmentStatusEnum = $shipmentStatusEnum;
Vue.prototype.$socketTypeEnum = $socketTypeEnum;
Vue.prototype.$wxScan = $wxScan;
Vue.prototype.$bluetooth = bluetooth;
Vue.prototype.$storageKeyEnum = $storageKeyEnum;

//注册全局过滤器
Object.keys(filters).forEach(key => {
	Vue.filter(key, filters[key])
})
Vue.config.productionTip = false
Vue.use(uView)
Vue.use(router)
Vue.component('navBar', navBar)
// #ifdef MP-WEIXIN || MP-ALIPAY
Vue.component('loginPopup', loginPopup)
//#endif
App.mpType = 'app'
const app = new Vue({
	 i18n,
	...App
})
export const eventBus = new Vue()
Vue.prototype._i18n = i18n

app.$mount()
